#include <twit/Twitter.h>
#include <stdio.h>

#if defined(WIN32)||defined(_WIN32)
#  if _DEBUG
#     pragma comment(lib,"../../../lib/twit4cpp.lib")
#  else
#     pragma comment(lib, "../../lib/twit4cpp.lib")
#  endif
#endif

using namespace std;
using namespace Twit;
int main(int argc, char* argv[])
{
   /* twit4cpp Sample Application */
   try
   {
      string
         customerKey("2rBtCAh5o10zMlS2FbRYAA"),
         customerSecert("MoZvHvDGbi6zoPu6Q1SZHsalGynP8qWt9dlB1NKlvQg");

	  string
		  aToken("access_token"),
		  aSecret("access_token_secret");

      Twitter twit(customerKey, customerSecert);
	  twit.setAccessToken(aToken, aSecret);
      
	  Resource::CTimeline& tl = twit.Timeline;
	  
     /***
      *	Public Timeline
      */
     puts("Public Timeline -----------------------------------------");
	  Value::Statuses val = tl.PublicTimeline.get();
	  for(size_t i=0; i<val.size(); i++)
	  {
		  Value::Status& status = val[i];
		  printf("username : %s\n", status.getUser()->getScreenName().c_str());
		  wprintf(L"text : %s\n", status.getText().c_str());
		  printf("---------------------------------------------\n");
		  //MessageBoxW(0,status.getText().c_str(),L"text",0);
	  }

     /***
      *	Friends Timeline
      */
     puts("Friends Timeline -----------------------------------------");
	  if( tl.FriendsTimeline.request() )
	  {
		  val = tl.FriendsTimeline.value();
		  for(size_t i=0; i<val.size(); i++)
		  {
			  Value::Status& status = val[i];
			  printf("username : %s\n", status.getUser()->getScreenName().c_str());
			  wprintf(L"text : %s\n", status.getText().c_str());
			  printf("---------------------------------------------\n");
		  }
	  }
	  else
	  {
		  const Error& e = tl.FriendsTimeline.getError();
		  printf("error message : %s\n", e.getMessage().c_str());
	  }

     /***
      *	Home Timeline
      */
     puts("Home Timeline -----------------------------------------");
	  val = tl.HomeTimeline.get();
	  for(size_t i=0; i<val.size(); i++)
	  {
		  Value::Status& status = val[i];
		  printf("username : %s\n", status.getUser()->getScreenName().c_str());
		  wprintf(L"text : %s\n", status.getText().c_str());
		  printf("---------------------------------------------\n");
	  }

     /***
      *	User Timeline
      */
     puts("User Timeline -----------------------------------------");
     val = tl.UserTimeline.get();
	  for(size_t i=0; i<val.size(); i++)
	  {
		  Value::Status& status = val[i];
		  printf("username : %s\n", status.getUser()->getScreenName().c_str());
		  wprintf(L"text : %s\n", status.getText().c_str());
		  printf("---------------------------------------------\n");
	  }

     /***
      *	Mentions
      */
     puts("Mentions -----------------------------------------");
     val = tl.Mentions.get();
     for(size_t i=0; i<val.size(); i++)
     {
        Value::Status& status = val[i];
        printf("username : %s\n", status.getUser()->getScreenName().c_str());
        wprintf(L"text : %s\n", status.getText().c_str());
        printf("---------------------------------------------\n");
     }

     /***
      *	Retweeted By Me
      */
     puts("Retweeted By Me -----------------------------------------");
     val = tl.RetweetedByMe.get();
     for(size_t i=0; i<val.size(); i++)
     {
        Value::Status& status = val[i];
        printf("username : %s\n", status.getUser()->getScreenName().c_str());
        wprintf(L"text : %s\n", status.getText().c_str());
        printf("---------------------------------------------\n");
     }

     /***
      *	Retweeted To Me
      */
     puts("Retweeted To Me -----------------------------------------");
     val = tl.RetweetedToMe.get();
     for(size_t i=0; i<val.size(); i++)
     {
        Value::Status& status = val[i];
        printf("username : %s\n", status.getUser()->getScreenName().c_str());
        wprintf(L"text : %s\n", status.getText().c_str());
        printf("---------------------------------------------\n");
     }

     /***
      *	Retweets Of Me
      */
     puts("Retweets Of Me -----------------------------------------");
     val = tl.RetweetsOfMe.get();
     for(size_t i=0; i<val.size(); i++)
     {
        Value::Status& status = val[i];
        printf("username : %s\n", status.getUser()->getScreenName().c_str());
        wprintf(L"text : %s\n", status.getText().c_str());
        printf("---------------------------------------------\n");
     }
   }
   catch(const Error& e)
   {
      printf("code : %d\n", e.getCode());
      printf("message : %s\n", e.getMessage().c_str());
   }   

   puts("Press Enter Key...");
   fflush(stdin);
   getc(stdin);
	return 0;
}


